<?php
     require '../db.func.php';
     require '../tools.func.php';
     require  'auth.php';
	require 'head.php';
	date_default_timezone_set("PRC");
	if(!empty(htmlentities(@$_POST['name']))){
		$name=$_POST['name'];
		$price=$_POST['price'];
		$code=$_POST['code'];
		$description=$_POST['description'];
		$stock=$_POST['stock'];
		$date=date("Y-m-d H:i:s");
		$prefix=getprefix();
		$sql="INSERT INTO {$prefix}product(name,price,code,stock,description,created_at) VALUES('$name','$price','$code','$stock','$description','$date')  ";
		execute($sql);
		setinfo('添加成功');
	}
	else{
		setinfo('商品名称不能为空');
	}
?>
				<div class="row">
					<div class="col-md-12">
						<div class="card">
							<div class="card-header card-header-primary">
								<h4 class="card-title">添加商品</h4>
								<p class="card-category">添加一个商品</p>
							</div>
							<div class="card-body">
								<?php if(hasinfo()) echo getinfo(); ?>
								<form  action="product_add.php"  method="post">
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="bmd-label-floating">商品名称</label>
												<input type="text" class="form-control" name="name">
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="bmd-label-floating">商品单价</label>
												<input type="number" class="form-control" name="price">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="bmd-label-floating">商品库存</label>
												<input type="number" class="form-control" name="stock">
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="bmd-label-floating">商品编号</label>
												<input type="text" class="form-control" name="code">
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-12">
											<div class="form-group">
												<label>商品描述</label>
												<div class="form-group bmd-form-group">
													<textarea class="form-control" rows="5" name="description"></textarea>
												</div>
											</div>
										</div>
									</div>
									<button type="submit" class="btn btn-primary pull-right">添加商品</button>
									<div class="clearfix"></div>
								</form>
							</div>
						</div>
					</div>

				</div>
<?php
	require 'foot.php';
?>